from flask import Blueprint


# 1.创建蓝图
admin_blu = Blueprint("admin", __name__, url_prefix='/admin')


# 请求钩子
@admin_blu.before_request
def check_superuser():
    is_admin = session.get('is_admin')

    if not is_admin and not request.url.endswith(url_for('admin.login')):
        return redirect(url_for('home.index'))

# 4. 让视图函数和主程序建立关联
from .views import *